import Vue from "vue";
import {actions} from '../base';

let url = 'admin/api/spread-data';

export default {
    namespaced: true,
    state: {
        all: [],
        spreadUsers: [],
        options: {
            dayType: {
                default: 1,
                list: [
                    {label: '次日', value: 1},
                    {label: '7天', value: 7},
                    {label: '15天', value: 15},
                    {label: '30天', value: 30},
                ]
            },
            chartType: {
                default: 1,
                list: [
                    {label: '整体', value: 1},
                    {label: '渠道类型', value: 2},
                    {label: '渠道', value: 3}
                ]
            },
        },
    },
    mutations: {
        SET_ALL (state, data) {
            state.all = data;
        },
        SET_SPREAD_USERS (state, data) {
            state.spreadUsers = data;
        },
    },
    actions: Object.assign({}, actions(url), {
        GetSpreadUsers({commit}) {
            return new Promise((resolve, reject) => {
                Vue.axios.get(`${url}/spread-users`).then(res => {
                    commit('SET_SPREAD_USERS', res.data.data);
                    return resolve(res);
                }).catch(error => {
                    return reject(error);
                })
            });
        },
        DayStat ({commit}, filter = {}) {
            return Vue.axios.get(`${url}/day-stat`, {
                params: filter,
            })
        },
        Daily({commit}, filter = {}) {
            return Vue.axios.get(`${url}/daily`, {
                params: filter,
            })
        },
        DailyAgent({commit}, filter = {}) {
            return Vue.axios.get(`${url}/daily-agent`, {
                params: filter,
            })
        },
        DailyAgentSub({commit}, filter = {}) {
            return Vue.axios.get(`${url}/daily-agent-sub`, {
                params: filter,
            })
        },
        DailyAgentReg({commit}, filter = {}) {
            return Vue.axios.get(`${url}/daily-agent-reg`, {
                params: filter,
            })
        },
        DailyAgentReg2Active({commit}, filter = {}) {
            return Vue.axios.get(`${url}/daily-agent-reg-2-active`, {
                params: filter,
            })
        },
        DailySimpleUpdate({commit}, filter = {}) {
            return Vue.axios.put(`${url}/daily-simple/${filter._id}`, filter)
        },
        MonthSimpleUpdate({commit}, filter = {}) {
            return Vue.axios.put(`${url}/month-simple/${filter._id}`, filter)
        },
        DailyBatchUpdate({commit}, filter = {}) {
            return Vue.axios.put(`${url}/daily-batch`, filter)
        },
        DailyAll({commit}, filter = {}) {
            return Vue.axios.get(`${url}/daily-all`, {
                params: filter,
            })
        },
        Month({commit}, filter = {}) {
            return Vue.axios.get(`${url}/month`, {
                params: filter,
            })
        },
        MonthBatchUpdate({commit}, filter = {}) {
            return Vue.axios.put(`${url}/month-batch`, filter)
        },
        MonthAll({commit}, filter = {}) {
            return Vue.axios.get(`${url}/month-all`, {
                params: filter,
            })
        },
        SourceLtv({commit}, filter = {}) {
            return Vue.axios.get(`${url}/source-ltv`, {
                params: filter,
            })
        },
        SourceLtvDetail({commit}, filter = {}) {
            return Vue.axios.get(`${url}/source-ltv-detail`, {
                params: filter,
            })
        },
        SourceLtvRoi({commit}, filter = {}) {
            return Vue.axios.get(`${url}/source-ltv-roi`, {
                params: filter,
            })
        },
        SourceLtvRoiChart({commit}, filter = {}) {
            return Vue.axios.get(`${url}/source-ltv-roi-chart`, {
                params: filter,
            })
        },
        Hour({commit}, filter = {}) {
            return Vue.axios.get(`${url}/hour`, {
                params: filter,
            })
        },
        HourSimple({commit}, filter = {}) {
            return Vue.axios.get(`${url}/hour-simple`, {
                params: filter,
            })
        },
        OperateTotal({commit}, filter = {}) {
            return Vue.axios.get(`${url}/operate-total`, {
                params: filter,
            })
        },
        SceneConsumeBulletChart({commit}, filter = {}) {
            return Vue.axios.get(`${url}/scene-consume-bullet-chart`, {
                params: filter,
            })
        },
        UserKeep({commit}, filter = {}) {
            return Vue.axios.get(`${url}/user-keep`, {
                params: filter,
            })
        },
        UserPayKeep({commit}, filter = {}) {
            return Vue.axios.get(`${url}/user-pay-keep`, {
                params: filter,
            })
        },
        UserPayRegister({commit}, filter = {}) {
            return Vue.axios.get(`${url}/user-pay-register`, {
                params: filter,
            })
        },
        UserKeepChart({commit}, filter = {}) {
            return Vue.axios.get(`${url}/user-keep-chart`, {
                params: filter,
            })
        },
        MarketReportStat({commit}, filter = {}) {
            return Vue.axios.get(`${url}/market-report-stat`, {
                params: filter,
            })
        }
    }),
    getters: {

    }
};
